package music.utils.captcha;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by pc01 on 11/7/2014.
 */
@WebServlet("/Captchk.do")
public class CaptchkServletUtil extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
        res.setContentType("text/html; charset=UTF-8");
        PrintWriter out = res.getWriter();

        // join.jsp 에서 생성한 captcha 문자를 확인해서 출력
        // out.print(req.getSession().getAttribute(""));

        // join.jsp에서 입력한 captcha 문자와
        // 세션에 저장한 captcha 문자를 비교해서 결과 출력

        if ( req.getSession().getAttribute("captcha").equals(req.getParameter("mycap")) )
            out.print("y");
        else
            out.print("n");

        out.flush();
        out.close();
    }
}
